/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package context;

import hibernate.conf.SpwHibernateUtil;
import hibernate.data.Users;
import java.util.Date;
import org.hibernate.Session;

/**
 *
 * @author Norteromius
 */
public class Client {
    
    
    private Users user = new Users();
    private boolean clientAuthorised = false;
    private Session  session = null;
    

    public Client() {
        this.session = SpwHibernateUtil.getSessionFactory().openSession();
        
    }

    public Users getUser() {
        return user;
    }
    
    public boolean autoriseClient(){
        if(user != null){
            this.clientAuthorised = true;
        }
        this.user.setUrsLastLogin(new Date());
        session.update(user);
        return this.clientAuthorised;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public boolean isClientAuthorised() {
        return clientAuthorised;
    }
    
        public Session getSession() {
        return session;
    }

    public void setSession(Session session) {
        this.session = session;
    }
    
    
    
    
}
